package com.mimc.service;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.extra.mail.MailAccount;
import cn.hutool.extra.mail.MailUtil;
import com.jfinal.aop.Inject;
import io.jboot.aop.annotation.Bean;

@Bean
public class ShEmailService {
    @Inject
    private ShSysConfigService sysConfigService;
    public void sendEamil(String to,String title,String content,Boolean isHtml){
        MailAccount account = new MailAccount();
        account.setHost(sysConfigService.getConfigValueByKey("email.host"));
        account.setPort(Integer.parseInt(sysConfigService.getConfigValueByKey("email.port")));
        account.setAuth(true);
        account.setSslEnable(true);
        account.setFrom(sysConfigService.getConfigValueByKey("email.user"));
        account.setUser(sysConfigService.getConfigValueByKey("email.user"));
        account.setPass(sysConfigService.getConfigValueByKey("email.password"));
        MailUtil.send(account, CollUtil.newArrayList(to), title, content, isHtml);
    }
}
